package com.example.mybatis_plus.config;



import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author GJH
 * @version V1.0
 * @Package com.example.mybatis_plus.config
 * @date 2022/4/27 22:04
 * @Copyright © XXXX-XXXX  搬砖工程师
 */
@Configuration
@MapperScan("com.example.mybatis_plus.mapper")

public class MqConfig {
    /**
     * 乐观锁插件  ,版本不一样，乐观锁的写法就不一样
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //注册分页插件
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        //注册乐观锁插件
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        return interceptor;

    }



}
